package com.guyj.baseapp.demo.gridtitle;

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.guyj.baseapp.R;
import com.guyj.common.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

public class GridTitleActivity extends BaseActivity {

    @Bind(R.id.recycler)
    RecyclerView recyclerView;
    GridAdapter adapter;
    GridLayoutManager glm;

    @Override
    public int getContentViewId() {
        return R.layout.activity_grid_title;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        setBack();
        setTitle("带title的grid列表");
    }

    @Override
    protected void initVariable() {
        glm=new GridLayoutManager(this,3);
        recyclerView.setLayoutManager(glm);
        List<List<String>> beans=new ArrayList<List<String>>();
        List<String> bean1=new ArrayList<>();
        List<String> bean2=new ArrayList<>();
        List<String> bean3=new ArrayList<>();
        List<String> bean4=new ArrayList<>();
        bean1.add("1");
        bean1.add("1");
        bean1.add("1");
        bean2.add("1");
        bean2.add("1");
        bean2.add("1");
        bean2.add("1");
        bean3.add("1");
        bean3.add("1");
        bean3.add("1");
        bean3.add("1");
        bean3.add("1");
        bean4.add("1");
        bean4.add("1");
        bean4.add("1");
        bean4.add("1");
        beans.add(bean1);
        beans.add(bean2);
        beans.add(bean3);
        beans.add(bean4);
        adapter=new GridAdapter(this,beans);
        recyclerView.setAdapter(adapter);
        glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                return adapter.getItemViewType(position)==0?glm.getSpanCount():1;
            }
        });
    }

    @Override
    protected void processLogic(Bundle savedInstanceState) {

    }
}
